package HomeWork;

class ListNode {
     int val;
    ListNode next;
     ListNode() {}
    ListNode(int val) { this.val = val; }
     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 }
class Solution {
    public ListNode reverseList(ListNode head) {
        ListNode slow = head;
        ListNode fast = head;
        while(fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
            if(slow == fast) {
                break;
            }
        }
        if(fast != null && fast.next != null) {
            slow = head;
            while(slow != fast) {
                slow = slow.next;
                fast = fast.next;
            }
            return fast;
        }
        else {
            return null;
        }
    }
}
public class Test_1 {
    public static void main(String[] args) {
        //先找到中间结点的位置
        ListNode slow = new ListNode();

        ListNode fast = new ListNode();
    }
}
